<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <h3>任意两个数累加</h3>
    <input id="num1" type="text"> <br/>
    <input id="num2" type="text"><br/>
    <input id="sum" type="text"><br/>
    <button onclick="count()">计算</button>


    <script>
        function count() {
            var num1 = document.getElementById('num1').value;
            var num2 = document.getElementById('num2').value;
            num1 = Number(num1);
            num2 = Number(num2);

            var sum = 0;
            for (var i = num1; i <= num2; i++) {
                sum += i;
            }
            document.getElementById('sum').value = sum;
        }
    </script>
</body>

</html>